<template>
  <div class="recharge">
    <el-dialog title="升级VIP" :visible.sync="isShow" center :before-close="close">
      <el-form :model="form" :rules="rules" ref="ruleForm" label-position="left" label-width="120px">
        <el-form-item label="VIP等级" prop="vip">
          <el-select v-model="form.vip" placeholder="请选择购买vip等级">
            <el-option
              v-for="item in vipLevels"
              :disabled="item.level <= $store.state.user.vip"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" >
        <el-button @click="close">取 消</el-button>
        <el-button type="primary" @click="submint">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>

export default {

  data () {

    return {
      isShow: false,
      form: {
        vip: ''
      },
      rules: {
        vip: [
          { required: true, message: '请选择vip等级', trigger: 'change' }
        ]
      },
      vipLevels: [
        {
          value: 'vip1',
          label: 'VIP',
          level: 1,
        },
        // {
        //   value: 'vip2',
        //   label: '银牌会员',
        //   level: 2,
        // },
        // {
        //   value: 'vip3',
        //   label: '金牌会员',
        //   level: 3,
        // },
        // {
        //   value: 'vip4',
        //   label: '钻石会员',
        //   level: 4,
        // }
      ],
      id: null
    }
  },
  methods: {
    show(data) {
      this.isShow = true
      // this.id = data.id
    },
    submint() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          this.$router.replace({
            name: 'payment',
            query: {
              type: 'buyVip',
              vip: btoa(this.form.vip),
              from: this.$route.path
            }
          })
        } else {
          return false;
        }
      })
    },

    close() {
      this.$refs['ruleForm'].resetFields()
      this.isShow = false
    }
  }
}
</script>

<style lang='less' type='text/css'>
  .recharge {
    .el-dialog {
      max-width: 500px;
    }
    .el-select {
      width: 100%;
    }
  }
</style>
